const store = {
    state: {
        num: 20
    },
    actions: { //只放同步的
        add1(newState: { num: number }, action: { type: string }) {
            newState.num++
        },
        add2(newState: { num: number }, action: { type: string, val: number }) {
            newState.num += action.val
        },
        add3(newState: { num: number }, action: { type: string, val: number }) {
            newState.num += action.val
        }
    },
    asyncActions: {
        asyncAdd1(dispatch: Function) {
            setTimeout(() => {
                dispatch({ type: "add1" })
            })
        }
    },
    // 名字统一管理
    // add1: "add1",
    // add2: "add2",
    // actionNames: {
    //     add1: "add1",
    //     add2: "add2",
    // }
    actionNames: {}
}
let actionNames = {}
for (let key in store.actions) {
    actionNames[key] = key
}

store.actionNames = actionNames

export default store